package 
{
	import flash.events.MouseEvent;
	import flash.display.Sprite;
	
	/**
	 * ...
	 * @author DarkGoodWIN
	 */
	public class TPrise extends InvControl
	{
		public var Price: int = 0;
		public var ID: int = 0;
		private var Room: TCaseRoom = null;
								
		private function ResByID(ID: int): Class
		{
			if (ID == 1)
				return res.prize_smile
			else if (ID == 2)
				return res.prize_heart
			else if (ID == 3)
				return res.prize_sun
			else if (ID == 4)
				return res.prize_moon
			else if (ID == 5)
				return res.prize_volt
			else if (ID == 6)
				return res.prize_clouf
			else
				return null;
		}
		
		private function HintByID(ID: int): String
		{
			if (ID == 1)
				return "Смайлик"
			else if (ID == 2)
				return "Сердце"
			else if (ID == 3)
				return "Солнце"
			else if (ID == 4)
				return "Месяц"
			else if (ID == 5)
				return "Молния"
			else if (ID == 6)
				return "Облако"
			else
				return '';
		}
		
		private function PriceByID(ID: int): int
		{
			if (ID == 1)
				return 100
			else if (ID == 2)
				return 200
			else if (ID == 3)
				return 300
			else if (ID == 4)
				return 400
			else if (ID == 5)
				return 500
			else if (ID == 6)
				return 600
			else
				return -1;
		}
		
		private function OnClick(e: MouseEvent): void
		{
			Room.OnPriseClick(this);
		}
		
		private function OnMDown(e: MouseEvent): void
		{
			Room.OnPriseMDown(this, e.stageX, e.stageY);
		}

		private function OnMUp(e: MouseEvent): void
		{
			Room.OnPriseMUp(this, e.stageX, e.stageY);
		}

		public function TPrise(Parent: TControl, Index: int, aRoom: TCaseRoom)
		{		
			super (ResByID(Index), Parent);	
			Room = aRoom;
			Price = PriceByID(Index);
			Hint = HintByID(Index);
			ID = Index;
			addEventListener(MouseEvent.CLICK, OnClick);
			addEventListener(MouseEvent.MOUSE_DOWN, OnMDown);
			addEventListener(MouseEvent.MOUSE_UP, OnMUp);
		}		
	}
	
}